<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>与解构赋值默认值结合使用</title>
  </head>
  <body>
    <pre>
        function foo({x,y=5}){
            console.log(x,y)
        }
        foo({ x: 1 }); //  1  5
        foo({ x: 1, y: 2 }); // 1  2
    </pre>
    <p>当执行函数的时候 传入的参数就等于在做解构赋值（给函数形参的解构赋值）</p>
    <p>例子 let {x,y=5} = {x:1}</p>
    <p>let {x,y=5} = {x:1,y:2}</p>
  </body>
</html>
<script>
  function foo({ x, y = 5 }) {
    console.log(x, y);
  }
  foo({ x: 1 }); //  1  5
  foo({ x: 1, y: 2 }); // 1  2
</script>
